EM

[Resolvido] colocar exausted nesse food

Por Emooooo, 04 de set. de 2018 em Resolvidos

10
1.7k
EmoooooE
04 de setembro de 2018 às 09:41

 

 

 

 

colocar exausted de 10 minutos nesse item +rep

 

 

 

 

 

local config = {

    storage = 10000, --use empty storage
    exhaust = 1800 --Exhaust is in seconds 600 equals 10min
}
 


local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3600000)
setConditionFormula(condition, 9.4, -24, 10.9, -24)

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(doAddCondition(cid, condition)) then
        doCreatureSay(cid, "Munch.",TALKTYPE_ORANGE_1)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "its speed was increased by 1 hour.")
        doRemoveItem(item.uid)
               else
    doPlayerSendCancel(cid, "You are full.")
    end

    return true
end

MarshmelloM
04 de setembro de 2018 às 14:43

@Emooooo

Spoiler


local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3600000)
setConditionFormula(condition, 9.4, -24, 10.9, -24)

if getPlayerStorageValue(cid, 4841) <= os.time() then
doPlayerSendCancel(cid, "Voce precisa esperar 10 minutos para usar")
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(doAddCondition(cid, condition)) then
        doCreatureSay(cid, "Munch.",TALKTYPE_ORANGE_1)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "its speed was increased by 1 hour.")
        doRemoveItem(item.uid)
        setPlayerStorageValue(cid, 4841, os.time + 600)
               else
    doPlayerSendCancel(cid, "You are full.")
    end

    return true
end

TESTE

EmoooooE
04 de setembro de 2018 às 15:25
42 minutos atrás, Marshmello disse:

@Emooooo

  Mostrar conteúdo oculto


local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3600000)
setConditionFormula(condition, 9.4, -24, 10.9, -24)

if getPlayerStorageValue(cid, 4841) <= os.time() then
doPlayerSendCancel(cid, "Voce precisa esperar 10 minutos para usar")
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(doAddCondition(cid, condition)) then
        doCreatureSay(cid, "Munch.",TALKTYPE_ORANGE_1)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "its speed was increased by 1 hour.")
        doRemoveItem(item.uid)
        setPlayerStorageValue(cid, 4841, os.time + 600)
               else
    doPlayerSendCancel(cid, "You are full.")
    end

    return true
end

TESTE

[4/9/2018 15:23:26] [Error - Test Interface] 
[4/9/2018 15:23:26] data/actions/scripts/other/FilledjalapeñoPeppers.lua
[4/9/2018 15:23:26] Description: 
[4/9/2018 15:23:26] (LuaInterface::luaGetCreatureStorage) Creature not found

[4/9/2018 15:23:26] [Error - Test Interface] 
[4/9/2018 15:23:26] data/actions/scripts/other/FilledjalapeñoPeppers.lua
[4/9/2018 15:23:26] Description: 
[4/9/2018 15:23:26] data/actions/scripts/other/FilledjalapeñoPeppers.lua:5: attempt to compare boolean with number
[4/9/2018 15:23:26] [Error - Event::checkScript] Cannot load script (data/actions/scripts/other/FilledjalapeñoPeppers.lua)

EmoooooE
04 de setembro de 2018 às 18:50
17 minutos atrás, Naruse disse:

Teste:

 

-- ARQUIVO .LUA QUALQUER USADO PARA TESTAR SCRIPTS.


local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3600000)
setConditionFormula(condition, 9.4, -24, 10.9, -24)

if getPlayerStorageValue(cid, gbb) - os.time() > 0 then
		doPlayerSendTextMessage(cid, 27, "Você precisa esperar 10 minutos para usar.")
	return true
	end

? 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(doAddCondition(cid, condition)) then
        doCreatureSay(cid, "Munch.",TALKTYPE_ORANGE_1)
            doPlayerSendTextMe?ssage(cid, MESSAGE_EVENT_ADVANCE, "its speed was increased by 1 hour.")
        doRemoveItem(item.uid)
        setPlayerStorageValue(cid, 4841, os.time + 600)
               else
    doPlayerSendCancel(cid, "You are full.")
    end

    return true
end

 

[4/9/2018 18:49:53] [Error - Test Interface] 
[4/9/2018 18:49:53] data/actions/scripts/other/FilledjalapeñoPeppers.lua
[4/9/2018 18:49:53] Description: 
[4/9/2018 18:49:53] data/actions/scripts/other/FilledjalapeñoPeppers.lua:5: attempt to perform arithmetic on a boolean value
[4/9/2018 18:49:53] [Error - Event::checkScript] Cannot load script (data/actions/scripts/other/FilledjalapeñoPeppers.lua)

CrypterC
04 de setembro de 2018 às 19:22
local config = {
    storage = 10000, --use empty storage
    exhaust = 1800 --Exhaust is in seconds 600 equals 10min
}
 
local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3600000)
setConditionFormula(condition, 9.4, -24, 10.9, -24)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if exhaustion.check(cid,config.storage) then
		return doPlayerSendCancel(cid, "You are full.")
	end
	doRemoveItem(item.uid)
	doAddCondition(cid, condition)
    doCreatureSay(cid, "Munch.",TALKTYPE_ORANGE_1)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "its speed was increased by 1 hour.")
	exhaustion.set(cid,config.storage,config.exhaust)
    return true
end

 

EmoooooE
04 de setembro de 2018 às 19:33
10 minutos atrás, Crypter disse:
local config = {
    storage = 10000, --use empty storage
    exhaust = 1800 --Exhaust is in seconds 600 equals 10min
}
 
local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3600000)
setConditionFormula(condition, 9.4, -24, 10.9, -24)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if exhaustion.check(cid,config.storage) then
		return doPlayerSendCancel(cid, "You are full.")
	end
	doRemoveItem(item.uid)
	doAddCondition(cid, condition)
    doCreatureSay(cid, "Munch.",TALKTYPE_ORANGE_1)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "its speed was increased by 1 hour.")
	exhaustion.set(cid,config.storage,config.exhaust)
    return true
end

 

[4/9/2018 19:31:8] [Error - LuaInterface::loadFile] data/actions/scripts/other/FilledjalapeñoPeppers.lua:2: '}' expected (to close '{' at line 1) near 'ï'
[4/9/2018 19:31:8] [Error - Event::checkScript] Cannot load script (data/actions/scripts/other/FilledjalapeñoPeppers.lua)
[4/9/2018 19:31:8] data/actions/scripts/other/FilledjalapeñoPeppers.lua:2: '}' expected (to close '{' at line 1) near 'ï'

EmoooooE
04 de setembro de 2018 às 19:34
9 minutos atrás, Naruse disse:

Tente

 

 

[4/9/2018 19:33:41] [Error - Test Interface] 
[4/9/2018 19:33:41] data/actions/scripts/other/FilledjalapeñoPeppers.lua
[4/9/2018 19:33:41] Description: 
[4/9/2018 19:33:41] (LuaInterface::luaGetPlayerFlagValue) Player not found

[4/9/2018 19:33:41] [Error - Test Interface] 
[4/9/2018 19:33:41] data/actions/scripts/other/FilledjalapeñoPeppers.lua
[4/9/2018 19:33:41] Description: 
[4/9/2018 19:33:41] (LuaInterface::luaGetCreatureStorage) Creature not found

[4/9/2018 19:33:41] [Error - Test Interface] 
[4/9/2018 19:33:41] data/actions/scripts/other/FilledjalapeñoPeppers.lua
[4/9/2018 19:33:41] Description: 
[4/9/2018 19:33:41] data/lib/034-exhaustion.lua:17: attempt to compare number with boolean
[4/9/2018 19:33:41] [Error - Event::checkScript] Cannot load script (data/actions/scripts/other/FilledjalapeñoPeppers.lua)

CrypterC
04 de setembro de 2018 às 19:38
Melhor resposta
local config = {
    storage = 10000, --use empty storage
    exhaust = 1800 --Exhaust is in seconds 600 equals 10min
}
 
local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3600000)
setConditionFormula(condition, 9.4, -24, 10.9, -24)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if exhaustion.check(cid,config.storage) then
		return doPlayerSendCancel(cid, "You are full.")
	end
	doRemoveItem(item.uid)
	doAddCondition(cid, condition)
    doCreatureSay(cid, "Munch.",TALKTYPE_ORANGE_1)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "its speed was increased by 1 hour.")
	exhaustion.set(cid,config.storage,config.exhaust)
    return true
end

Tinha uma simbolo mal formatado perdido no código, recomendo sempre que for fazer script em lua formatar o arquivo para ANSII

Editado Setembro 4 por Crypter

EmoooooE
04 de setembro de 2018 às 19:49
11 minutos atrás, Crypter disse:
local config = {
    storage = 10000, --use empty storage
    exhaust = 1800 --Exhaust is in seconds 600 equals 10min
}
 
local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3600000)
setConditionFormula(condition, 9.4, -24, 10.9, -24)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if exhaustion.check(cid,config.storage) then
		return doPlayerSendCancel(cid, "You are full.")
	end
	doRemoveItem(item.uid)
	doAddCondition(cid, condition)
    doCreatureSay(cid, "Munch.",TALKTYPE_ORANGE_1)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "its speed was increased by 1 hour.")
	exhaustion.set(cid,config.storage,config.exhaust)
    return true
end

Tinha uma simbolo mal formatado perdido no código, recomendo sempre que for fazer script em lua formatar o arquivo para ANSII

pego! thx

5 meses depois...
MarshmelloM
14 de fevereiro de 2019 às 16:04
O pedido neste tópico de foi atendido e/ou o autor do tópico resolveu sua duvida. Este tópico está fechado e foi movido para Pedidos - Resolvidos. Se você tiver outros pedidos, crie um novo tópico.